package com.B1线程优先级;

import com.A1yeild方法的使用.MyThread;

/**
 * @Auther: SJZ    2907374717@qq.com
 * @Date: 2019/3/12 21:49
 * @Description:多线程优先级测试
 * priority:优先;优先权。
 * MIN_PRIORITY
 * NORM_PRIORITY
 * MAX_PRORITY
 *
 * 线程优先级的特性。
 * 1.继承性
 * 在JAVA中，线程的优先级具有继承性，比如A线程启动B线程，则B线程的优先级与
 * A是一样的。
 * */
public class PriorityRandomTest {
    static class MyThread1 extends Thread{
        public void run(){
            System.out.println("MyThread1 run prority="+this.getPriority());
            MyThread2 myThread2 = new MyThread2();
            myThread2.start();

        }
    }
    static class MyThread2 extends Thread{
        public void run(){
            System.out.println("MyThread2 run prority="+this.getPriority());
        }
    }

    public static void main(String[] args) {
        System.out.println("main thread begin priotity="+Thread.currentThread().getPriority());
        Thread.currentThread().setPriority(6);
        System.out.println("main thread end priotity="+Thread.currentThread().getPriority());
        MyThread1 thread1= new MyThread1();
        thread1.start();
    }
}
